package de.hska.master.model;

import java.util.ArrayList;
import java.util.List;

public class Model {

	protected ArrayList<Point> points = null;
	private ArrayList<Point> convexHull = null;

	/**
	 * Prepares the members.
	 */
	public Model() {
		this.points = new ArrayList<Point>();
		this.convexHull = new ArrayList<Point>();
	}

	/**
	 * Getter of member points.
	 * 
	 * @return
	 */
	public Point[] getPoints() {
		Point[] pointsCopy = points.toArray(new Point[points.size()]);
		return pointsCopy;
	}

	public List<Point> getPointsAsList() {
		List<Point> copyOfPoints = new ArrayList<Point>(points);
		return copyOfPoints;
	}

	/**
	 * Getter of member convexHull
	 * 
	 * @return member convexHull
	 */
	public Point[] getConvexHull() {
		Point[] pointsCopy = convexHull.toArray(new Point[convexHull.size()]);
		return pointsCopy;
	}

	/**
	 * Adds a point to the list of points.
	 * 
	 * @param p
	 *            new/added point
	 */
	public void addPoint(Point p) {
		points.add(p);
	}

	/**
	 * Adds a set of points to the list of points.
	 * 
	 * @param p
	 *            new/added points
	 */
	public void addAllPoints(ArrayList<Point> allPoints) {
		points.addAll(allPoints);	
	}

	/**
	 * Adds a point to the list of points on convex hull
	 * 
	 * @param p
	 *            new/added point
	 * @throws InterruptedException
	 */
	public void addPointOnConvexHull(Point p) throws InterruptedException {
		convexHull.add(p);
	}
	

	/**
	 * Adds a set of points to the list of points on convex hull
	 * 
	 * @param algorithmSolution
	 *            new/added points
	 * @throws InterruptedException
	 */
	public void addPointsOnConvexHull(List<Point> algorithmSolution) {
		convexHull.addAll(algorithmSolution);
	}

	/**
	 * Removes a point from the list of convexhull-points.
	 * 
	 * @param pointToRemove
	 *            point to remove
	 * @throws InterruptedException
	 */
	public void removePointOnConvexHull(Point pointToRemove)
			throws InterruptedException {
		convexHull.remove(pointToRemove);
	}

}
